<?php
namespace app\admin\validate;

use think\Validate;

class Goods extends Validate
{
    protected $rule = [
        'title' => 'require',
        'id' => 'require|number',
        'listorder' => 'require|number',
        'status' => ['require','in'=>'0,1,99'],
        'is_index_recommend' => ['require','in'=>'0,1']
    ];

    protected $message = [
        'title' => '商品名不能为空',
        'id.require' => '分类id不能为空',
        'id.number'   => '分类id必须是数字',
        'listorder.require' => '排序字段不能为空',
        'listorder.number' => '排序字段必须是数字',
        'status.require' => '状态不能为空',
        'status.in' => '状态类型不符合要求',
        'is_index_recommend.require' => '状态不能为空',
        'is_index_recommend.in' => '状态类型不符合要求',
    ];

    protected $scene = [
        'goods_listorder' => ['listorder', 'id'],
        'goods_status' => ['id','status'],
        'goods_recommend' => ['id','recommend'],
        'goods_update' => ['id'],
    ];
}
